LearningDataModel.CreateComment Method

Creates a Comment object, which may then be used to be added to the CommentsFromLearner list.

Parent Type: LearningDataModel

Namespace: Microsoft.LearningComponents.DataModel

Assembly: Microsoft.LearningComponents.dll

Syntax
C#

public Comment CreateComment ()

Return Value

A new Comment object associated with this LearningDataModel.

Exceptions
Exception type Condition
InvalidOperationException

Thrown if this LearningDataModel object cannot be written to.

Example

The following example demonstrates creating a new comment and adding it to the CommentsFromLearner collection.

C#
LearningSession session = ... ; // get LearningSession object

Comment c = session.CurrentActivityDataModel.CreateComment();
c.Location = "Question #3";
c.CommentText = "I don't understand this question.";
c.Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.ffZ");
session.CurrentActivityDataModel.CommentsFromLearner.Add(c);